package com.itheima.mymethod;

public class Method13maxandmin {
    public static void main(String[] args) {
       int[] arr = {11,22,336,44,55};
       //注意传递的是地址
       int[] maxandmin = getMaxandMin(arr);
        System.out.println(maxandmin[0]);
        System.out.println(maxandmin[1]);
    }
    public static int[] getMaxandMin(int[] arr){
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]){
                max = arr[i];
            }
        }

        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (min > arr[i]){
                min = arr[i];
            }
        }
        //数组中也可以变量
        int[] maxandmin = {max,min};
        //返回的是数组 类型int[]
        return maxandmin;
    }
}
